import Cookies from 'js-cookie'

const TokenKey = 'Admin-Token'

export function getToken(k = TokenKey) {
  return Cookies.get(k)
}

export function setToken(token, k = TokenKey) {
  return Cookies.set(k, token)
}

export function removeToken(k = TokenKey) {
  return Cookies.remove(k)
}

export const setDb = (k, v) => {
  localStorage.setItem(k, typeof v === 'object' && JSON.stringify(v) || v )
}
export const getDb = k => {
  return localStorage.getItem(k)
}
export const removeDb = k => {
  localStorage.removeItem(k)
}